package cn.unknowpupil.init.domain.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * Created at 2020/10/19 by w10g <br>
 * Initialize LoginUser ... <br>
 *
 * @author unknowpupil
 * @since 0.0.1
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LoginUser implements UserDetails {
    private static final long serialVersionUID = 8536942569544774727L;
    private Long id;

    private String username;

    private String password;

    private Long pid;

    private boolean multilateralLogin;
    /**
     * 是否是管理员
     */
    private boolean isAdmin;
    /**
     * 用户唯一标识
     */
    private String token;

    /**
     * 登录时间
     */
    private Long loginTime;

    /**
     * 过期时间
     */
    private Long expireTime;

    /**
     * 登录IP地址
     */
    private String ipaddr;

    /**
     * 登录地点
     */
    private String loginLocation;

    /**
     * 浏览器类型
     */
    private String browser;

    /**
     * 操作系统
     */
    private String os;

    private boolean enabled;

    private boolean isAccountNonExpired;

    private boolean isAccountNonLocked;

    private boolean isCredentialsNonExpired;

    /**
     * 权限列表
     */
    private Collection<? extends GrantedAuthority> authorities;


    public LoginUser(Long id, Long pid,String username, String password, boolean isAdmin,Collection<? extends GrantedAuthority> authorities) {
        this.id = id;
        this.pid = pid;
        this.username = username;
        this.password = password;
        this.authorities = authorities;
        this.isAdmin = isAdmin;
        this.multilateralLogin = false;
        this.enabled = true;
        this.isAccountNonExpired = true;
        this.isAccountNonLocked = true;
        this.isCredentialsNonExpired = true;
    }
}
